package com.jike.noobmoney.mvp.view.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.jike.noobmoney.R;
import com.jike.noobmoney.adapter.ChannelsAdapter;
import com.jike.noobmoney.entity.MyTaskChannelEntity;
import com.jike.noobmoney.mvp.view.fragment.rank.TopInviteFragment;
import com.jike.noobmoney.mvp.view.fragment.rank.TopKtouFragment;
import com.jike.noobmoney.mvp.view.fragment.rank.TopPushFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Create by xuke on 2019/02/28
 * 上周排行榜
 */
public class RankTwoActivity extends BaseActivity {

    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.channelTab)
    TabLayout channelTab;
    @BindView(R.id.viewpger)
    ViewPager viewpger;

    private List<MyTaskChannelEntity> tabNameList = new ArrayList<>();
    private List<Fragment> newsFragmentList = new ArrayList<>();

    @Override
    protected int layoutResID() {
        return R.layout.activity_rank;
    }
    /**
     * 如果要全屏,重写这个方法返回false
     */
    public Boolean isfits() {
        return true;
    }

    /**
     * 如果要白色主题,重写这个方法返回false
     */
    public boolean ismain() {
        return true;
    }

    @Override
    protected void initData() {
        tvTitle.setText("上周排行榜");
        tabNameList.add(new MyTaskChannelEntity("超级发布者"));
        tabNameList.add(new MyTaskChannelEntity("最佳投手"));
        tabNameList.add(new MyTaskChannelEntity("金牌推广"));

        for (int i = 0; i < tabNameList.size(); i++) {
            channelTab.addTab(channelTab.newTab().setText(tabNameList.get(i).getTitle()));
        }

        Bundle bundle = new Bundle();
        bundle.putString("type","1");
        bundle.putString("mouth","0");

        TopPushFragment topPushFragment = new TopPushFragment();
        topPushFragment.setArguments(bundle);
        TopKtouFragment ktouFragment = new TopKtouFragment();
        ktouFragment.setArguments(bundle);
        TopInviteFragment topInviteFragment = new TopInviteFragment();
        topInviteFragment.setArguments(bundle);
        newsFragmentList.add(topPushFragment);
        newsFragmentList.add(ktouFragment);
        newsFragmentList.add(topInviteFragment);

        ChannelsAdapter adapter = new ChannelsAdapter(getSupportFragmentManager(), tabNameList, newsFragmentList);
        viewpger.setAdapter(adapter);
        channelTab.setupWithViewPager(viewpger);
        viewpger.setOffscreenPageLimit(tabNameList.size());

        viewpger.setCurrentItem(0);
    }


    @OnClick({R.id.iv_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }
}
